class Tag < ActiveRecord::Base
  def self.cloud(tags, category_list)
    if tags and tags.length > 0
        max = 0
        min = tags[0].count.to_i
        tags.each do |tag|
            count = tag.count.to_i
            max = count if count > max
            min = count if count < min
        end
        
        divisor = ((max - min) / category_list.size) + 1
        
        tags.each do |tag|
            yield tag.name, category_list[(tag.count.to_i - min) / divisor]             
        end
    end
  end
end
